package com.winshare.saleAssistant.domain.dto.req;

import com.winshare.saleAssistant.exception.BusinessException;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.util.CollectionUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Objects;

@ApiModel
public class ProductReadCountDTO {

    @NotNull(message = "产品Id不可以为空")
    @Range(min = 1, message = "产品Id为大于或等1的正整数")
    @ApiModelProperty(value = "产品Id不可以为空")
    private Integer id;

    @NotBlank(message = "分类描述：宣传模式，学习模式")
    @Length(min = 4, max = 4, message = "分类描述：宣传模式，学习模式")
    @ApiModelProperty(value = "分类描述：宣传模式，学习模式")
    private String  pattern;

    public ProductReadCountDTO() {
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getPattern() {
        return pattern;
    }

    public void setPattern(String pattern) {
        this.pattern = pattern;
    }

    public void validatePattern() {
        if(Objects.equals(this.pattern,"宣传模式") || Objects.equals(this.pattern,"学习模式")) {
            return;
        }
        throw new BusinessException("分类描述类型只能填写 宣传模式 或 学习模式");
    }
}
